home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / docs / misc / amigapl.9903.lzh / amigapl.9903 / pci.lzx / Examples / pcinet / sana_test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-03  |  1.5 KB  |  57 lines

  1. /* testowanie device SANA II */
  2. #include <proto/exec.h>
  3. #include <stdio.h>
  4. #include <devices/sana2.h>
  5. #include <string.h>
  6.  
  7. __asm __saveds ULONG CopyFromBuffProc(register __a0 void * to, register __a1 * from,
  8.                               register __d0 ULONG n)
  9. {
  10.     memcpy(from, to, n);
  11.     return n;
  12. }
  13.  
  14. __asm __saveds ULONG CopyToBuffProc(register __a0 void * to, register __a1 * from,
  15.                               register __d0 ULONG n)
  16. {
  17.     memcpy(from, to, n);
  18.     return n;
  19. }
  20.  
  21. int main(int argc, char * argv[])
  22. {
  23.     struct MsgPort * mp = NULL;
  24.     struct IOSana2Req * req = NULL;
  25.     int error;
  26.     
  27.     ULONG TAG_LIST[] = { S2_CopyToBuff, CopyToBuffProc,
  28.                          S2_CopyFromBuff, CopyFromBuffProc,
  29.                          TAG_DONE, 0 };
  30.     
  31.     mp = CreateMsgPort();
  32.     if (mp)
  33.     {
  34.         printf("MsgPort OK !!\n");
  35.         req = (struct IOSana2Req *)CreateExtIO(mp, sizeof(struct IOSana2Req));
  36.         if (req)
  37.         {
  38.             printf("IO request OK!!!\n");
  39.             req->ios2_BufferManagement = TAG_LIST;
  40.             error = OpenDevice("pcinet.device", 0, (struct IORequest *)req, 0);
  41.             if (error == 0)
  42.             {
  43.                 printf("Device OK!!\n");
  44.                 CloseDevice((struct IORequest *)req);
  45.             }
  46.             else
  47.                printf("Open device failed %d!!\n", error);
  48.             DeleteExtIO((struct IORequest *)req);
  49.         }
  50.         else
  51.             printf("CreateExtIO failed!!\n");
  52.         DeleteMsgPort(mp);
  53.     }
  54.     else
  55.         printf("Create MsgPort failed !!\n");
  56. }
  57.